﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using WebNext.DataAccess.Repositories;
using WebNext.Domain.Interfaces;
using WebNext.Domain.Entities;
using WebNext.DataAccess.Infrastructure;
using log4net;
using log4net.Config;
using System.Net.Mail;
using System.Net;
using System.Xml.Serialization;
using System.IO;
using System.Text.RegularExpressions;

namespace WebNext.ConsoleTest
{
	class Program
	{
		static void Main(string[] args)
		{
			using (ISessionFactory sessionFactory = CreateSessionFactory())
			{
				string userName = Environment.UserName;
				using (ISession session = sessionFactory.OpenSession(new NHibernateEntityInterceptor(userName)))
				{
					NHibernateContext context = new NHibernateContext(session);
					EntriesRepository repository = new EntriesRepository(context);
					repository.CultureId = CultureId.PL;

					IEnumerable<Entry> entries = repository.GetArchiveEntries(EntryType.Blog, 0, 20, 2012, 6, false);
					Console.WriteLine(entries.Count());
				}
			}
		}

		private static ISessionFactory CreateSessionFactory()
		{
			return Fluently.Configure()
						.Database(MsSqlConfiguration.MsSql2008.ConnectionString("Data Source=localhost;Initial Catalog=WebNext2;Integrated Security=True;").ShowSql())
						.Mappings(m => m.FluentMappings.AddFromAssemblyOf<EntriesRepository>())
						.BuildSessionFactory();
		}
	}
}
